// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

const int N = 1e5+50;

int t, n;
const int M = 7;

inline void update(int &a, int &b, int &c, int x) {
    if (x & 1) ++c;
    if ((x >> 1) & 1) ++b;
    if ((x >> 2) & 1) ++a;
}

int bitcount(int x) {
    int res = 0;
    for (; x; x>>=1)
        res += x & 1;
    return res;
}

int main(int argc, char const *argv[]) {
    // code
    scanf("%d", &t);
    for (int kk=0; kk<t; ++kk) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        int ans = 0;
        for (int i=0; i<(1<<M); ++i) {
            int ax = 0, bx = 0, cx = 0;
            for (int j=0; j<M; ++j) {
                if (!((i >> j) & 1)) continue;
                update(ax, bx, cx, j+1);

                // if (i == 11) dbg(ax, bx, cx, j+1);
            }
            if (ax <= a && bx <= b && cx <= c && bitcount(i) > ans)
                ans = bitcount(i);
        }
        printf("%d\n", ans);
    }
    return 0;
}
